package cn.zd.erp.auth.dep.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import cn.zd.erp.auth.dep.dao.dao.OrgDao;
import cn.zd.erp.auth.dep.vo.Torganization1;
import cn.zd.erp.util.base.Organization;

@Repository
public class OrgDaoImpl extends HibernateDaoSupport implements OrgDao{
	@Autowired
	public void setMySessionFactory(SessionFactory sessionFactory){  
	    super.setSessionFactory(sessionFactory);  
	}  
	public void sava(Torganization1 torganization) {
		this.getHibernateTemplate().saveOrUpdate(torganization);
	}
	
	public List<Torganization1> getAllOrg() {
		String hql = "select distinct t from Torganization t order by t.seq";
		List<Torganization1> list = this.getHibernateTemplate().find(hql);
		return list;
	}
	

	public void delete(Torganization1 torganization) {
		this.getHibernateTemplate().delete(torganization);
	}

	public Torganization1 getOrgById(Long id) {
		return this.getHibernateTemplate().get(Torganization1.class,id);
	}

}
